<template>
  <div :class="[prefixCls, reverseColor && 'reverse-color' ]">
    <span>
      <slot name="term"></slot>
      <span class="item-text">
        <slot>{{ typeof slotText === 'function' && slotText() || slotText }}</slot>
      </span>
    </span>
    <span v-if="slotText.substr(0,slotText.length-1)>0" :class="['up']"><a-icon :type="`caret-up`"/></span>
    <span v-else-if="slotText.substr(0,slotText.length-1)<0" :class="['down']"><a-icon :type="`caret-down`"/></span>
    <span v-else :class="[flag]"><a-icon :type="`caret-${flag}`"/></span>
  </div>
</template>

<script>
export default {
  name: 'Trend',
  props: {
    prefixCls: {
      type: String,
      default: 'ant-pro-trend'
    },
    /**
       * 上升下降标识：up|down
       */
    flag: {
      type: String,
      required: true
    },
    /**
       * 颜色反转
       */
    reverseColor: {
      type: Boolean,
      default: false
    },
    slotText: {
      type: [Function, Number, String],
      required: false,
      default: ''
    }
  }
}
</script>

<style lang="less" scoped>
  @import "index";
</style>
